package com.andrew.pegSolitareEngine;

import android.content.Context;

// this class should create a new Board object
public class BoardFactory {
	private Hole [][] arraysOfHoles;
	private final int SIZE_OF_BOARD = 5;  // SIZE_OF_BOARD refers the the length of one side
	Board aBoard;
	Context context;
	
	public BoardFactory(Context context){
		this.context = context;
	}
	
	// instantiate the new board 
	public void createBoard(int sizeOfBoard){
		int column; // number of columns in board
		int row;	// number of rows in board

		
		arraysOfHoles = new Hole[sizeOfBoard][]; // initialize array of rows
		
		// allocate an array of rows
		for (row=0; row < arraysOfHoles.length; row++){
			arraysOfHoles[row] = new Hole[row+1];
			
			// allocate each hole in a single row
			for (column=0; column < arraysOfHoles[row].length; column++)	{
				arraysOfHoles[row][column]= new Hole(context,row, column);
			}
		}
		
		aBoard = new Board(arraysOfHoles, context);
	}
	
	// return the new board
	public Board getBoard(){
		return aBoard;
	}
	
}
